package com.study.ctripapollo.utils;


import com.study.ctripapollo.entity.common.Result;
import com.study.ctripapollo.enums.common.ResultCodEnum;

public final class ResultUtil {

    public static Result success(Object object) {
        return new Result(ResultCodEnum.SUCCESS.getCode(), ResultCodEnum.SUCCESS.getDesc(), object);
    }

    public static Result success() {
        return new Result(ResultCodEnum.SUCCESS.getCode(), ResultCodEnum.SUCCESS.getDesc());
    }

    public static Result success(String message) {
        return new Result(ResultCodEnum.SUCCESS.getCode(), message);
    }

    public static Result fail() {
        return new Result(ResultCodEnum.FAIL.getCode(), ResultCodEnum.FAIL.getDesc());
    }

    public static Result fail(String message) {
        return new Result(ResultCodEnum.FAIL.getCode(), message);
    }

    public static Result fail(Integer code, String message) {
        return new Result(code, message);
    }

    public static Result exception() {
        return new Result(ResultCodEnum.EXCEPTION.getCode(), ResultCodEnum.EXCEPTION);
    }

    public static Result exception(String message) {
        return new Result(ResultCodEnum.EXCEPTION.getCode(), message);
    }

    public static Result exception(Integer code, String message) {
        return new Result(code, message);
    }

    public static boolean isSuccess(Integer code) {
        return ResultCodEnum.SUCCESS.getCode().equals(code);
    }

    public static boolean isFail(Integer code) {
        return ResultCodEnum.FAIL.getCode().equals(code);
    }

    public static boolean isException(Integer code) {
        return ResultCodEnum.EXCEPTION.getCode().equals(code);
    }

}
